package com.example.springbootmybatis.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ECharsMapper {
@Select("SELECT IFNULL(count, 0) AS count\n" +
        "FROM (\n" +
        "         SELECT 1 AS month UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION\n" +
        "         SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION\n" +
        "         SELECT 9 UNION SELECT 10 UNION SELECT 11 UNION SELECT 12\n" +
        "     ) AS MONTHS\n" +
        "         LEFT JOIN (\n" +
        "    SELECT MONTH(date1) AS month, COUNT(*) AS count\n" +
        "    FROM borrowtable\n" +
        "    GROUP BY month\n" +
        ") AS DATA ON MONTHS.month = DATA.month;")
    public List<Integer> getBorrowMonth();
@Select("SELECT  IFNULL(count, 0) AS count\n" +
        "FROM (\n" +
        "         SELECT 1 AS month UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION\n" +
        "         SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION\n" +
        "         SELECT 9 UNION SELECT 10 UNION SELECT 11 UNION SELECT 12\n" +
        "     ) AS MONTHS\n" +
        "         LEFT JOIN (\n" +
        "    SELECT MONTH(date2) AS month, COUNT(*) AS count\n" +
        "    FROM borrowtable\n" +
        "    GROUP BY month\n" +
        ") AS DATA ON MONTHS.month = DATA.month;")
    public List<Integer> getReturnMonth();
}
